<?xml version="1.0" encoding="UTF-8"?>
<!--
	
                 Springs On Rails
                 Copyright [2007] [Sunny Liu]

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.	
-->
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="
       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">

<#if appConfig.webServiceApp >
<bean name="/Service" class="org.codehaus.xfire.spring.remoting.XFireExporter">
    <property name="serviceInterface" value="${appConfig.outputPackageName}.service.${appConfig.appJavaName}Service"/>
    <property name="serviceBean" ref="${appConfig.appJavaName?uncap_first}Service">    	
    </property>
    <!-- the XFire bean is defined in the xfire.xml file -->
    <property name="xfire" ref="xfire"/>
  </bean>
<#else>
	<#if appConfig.multipleController >
	<#list entities as entity>
	  	<bean id="${entity.normalizedJavaName}ListViewController" class="${appConfig.outputPackageName}.controller.${entity.javaName}ListViewController">
			<property name="${appConfig.appJavaName?uncap_first}Service"><ref bean="${appConfig.appJavaName?uncap_first}Service"/> </property>
		</bean>
		<bean id="${entity.normalizedJavaName}DetailViewController" class="${appConfig.outputPackageName}.controller.${entity.javaName}DetailViewController">
			<property name="${appConfig.appJavaName?uncap_first}Service"><ref bean="${appConfig.appJavaName?uncap_first}Service"/> </property>
		</bean>
		<bean id="${entity.normalizedJavaName}AddController" class="${appConfig.outputPackageName}.controller.${entity.javaName}AddController">
			<property name="${appConfig.appJavaName?uncap_first}Service"><ref bean="${appConfig.appJavaName?uncap_first}Service"/> </property>
		</bean>
		<bean id="${entity.normalizedJavaName}UpdateController" class="${appConfig.outputPackageName}.controller.${entity.javaName}UpdateController">
			<property name="${appConfig.appJavaName?uncap_first}Service"><ref bean="${appConfig.appJavaName?uncap_first}Service"/> </property>
		</bean>
		<bean id="${entity.normalizedJavaName}DeleteController" class="${appConfig.outputPackageName}.controller.${entity.javaName}DeleteController">
			<property name="${appConfig.appJavaName?uncap_first}Service"><ref bean="${appConfig.appJavaName?uncap_first}Service"/> </property>
		</bean>
	</#list>
	<#else>	
	<#list entities as entity>
	  	<bean id="${entity.normalizedJavaName}Controller" class="${appConfig.outputPackageName}.controller.Spring${entity.javaName}Controller">
			<property name="${appConfig.appJavaName?uncap_first}Service"><ref bean="${appConfig.appJavaName?uncap_first}Service"/> </property>
		</bean>	
	</#list>	
	</#if>		
	<bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">        
		<property name="mappings">            
			<props>	
				<#if appConfig.multipleController >							
				<#list entities as entity>
				<prop key="${entity.normalizedJavaName}ListView">${entity.normalizedJavaName}ListViewController</prop>
				<prop key="${entity.normalizedJavaName}DetailView">${entity.normalizedJavaName}DetailViewController</prop>
				<prop key="add${entity.javaName}">${entity.normalizedJavaName}AddController</prop>
				<prop key="update${entity.javaName}">${entity.normalizedJavaName}UpdateController</prop>
				<prop key="delete${entity.javaName}">${entity.normalizedJavaName}DeleteController</prop>
				</#list>	
				<#else>
				<#list entities as entity>
						<prop key="${entity.normalizedJavaName}">${entity.normalizedJavaName}Controller</prop>
				</#list>			
				</#if>			
			</props>        
		</property>    
	</bean>	
	<bean id="viewResolver1" class="${appConfig.outputPackageName}.web.view.FlexXMLViewResolver">
    	<property name="view" ref="xmlView"></property>
    </bean>    
    <bean id="xmlView" class="${appConfig.outputPackageName}.web.view.FlexXMLView">
		<property name="serilizerFactory" ref="serializerFactroy"></property>
	</bean>
	<bean id="serializerFactroy" class="${appConfig.outputPackageName}.xml.ObjectXMLSerializerFactory" >
		<property name="objectXMLSerializers">
			<list>
				<!--  Add more your own ObjectXMLSerializer here, it has to be type -->
				<!--  of ObjectXMLSerializer. -->
				<!--
				<bean class="com.nyse.regtech.budget.xml.ServerXMLSerializer"></bean>
				-->		
			</list>
		</property>
	</bean>
	<bean id="viewResolver2" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
		<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
		<property name="prefix" value="/WEB-INF/jsp/"/>
		<property name="suffix" value=".jsp"/>
	</bean>	
</#if>
</beans>
